﻿Ext.define('SmartClient.view.SearchOrdersView',
   {
      extend: 'Ext.form.Panel',
      controller: 'SmartClient.controller.SearchOrdersController',

      // Fields will be arranged vertically, stretched to full width
      layout: 'anchor',
      defaults: { anchor: '100%' },

      title: 'Search order',
      bodyPadding: 5,
      buttonAlign: 'center',
      titleAlign: 'center',
      width: 300,
      defaultType: 'textfield',

      renderTo: Ext.getBody(),

      items:
         [
            {
               itemId: 'orderNumberField',
               fieldLabel: 'Order number',
               allowBlank: true,
               enableKeyEvents: true
            },
            {
               xtype: 'datefield',
               itemId: 'orderingDateField',
               fieldLabel: 'Ordering date',
               allowBlank: true,
               enableKeyEvents: true
            }
         ],

      buttons:
         [
            {
               itemId: 'searchButton',
               text: 'Search',
               formBind: true, // Only enabled once the form is valid
               disabled: true
            }
         ],

      listeners:
      {
         afterlayout: function()
         {
            this.down('textfield').focus(false, 50);
            this.center();
         }
      }
   });